package com.zhongkai.controller;

import com.zhongkai.app.service.GuardService;
import com.zhongkai.model.utils.TTHelp;
import com.zhongkai.model.utils.ZhongkaiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 维修端用户
 * */
@Controller
public class GuardController {

    @Autowired
    private GuardService guardService;



    /**
     * 添加维修端用户
     *
     * @param gua_sex   性别
     * @param gua_name  姓名
     * @param gua_user  用户名
     * @param gua_phone 电话
     * @param gua_pass  密码
     * @param gua_state 状态
     */

    @RequestMapping(value = "/guard/add", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult guard_add( String gua_sex, String gua_name, String gua_user, String gua_phone, String gua_pass, String gua_state) {


        String uuid = TTHelp.generate();
        ZhongkaiResult result = guardService.addGuard(uuid,gua_sex,gua_name,gua_user,gua_phone,gua_pass,gua_state);

        return result;
    }




    /**
     * 修改维修端用户

     * @param gua_sex   性别
     * @param gua_name  姓名
     * @param gua_user  用户名
     * @param gua_phone 电话
     * @param gua_pass  密码
     * @param gua_state 状态
     */

    @RequestMapping(value = "/guard/update", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult guard_update(String uuid , String gua_sex, String gua_name, String gua_user, String gua_phone, String gua_pass, String gua_state) {


        ZhongkaiResult result = guardService.updateGuard(uuid,gua_sex,gua_name,gua_user,gua_phone,gua_pass,gua_state);

        return result;
    }






    /**
     * 删除维修端用户
     *
     * @param uuid 用户id
     */

    @RequestMapping(value = "/guard/remove", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult guard_remove(String uuid ) {


        ZhongkaiResult result = guardService.removeGuard(uuid);

        return result;
    }


    /**
     * 维修端列表
     *
     * @param page 当前页数
     * @param rows 每页数据条数
     * @param gua_state 用户状态
     */

    @RequestMapping(value = "/guard/list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult guard_list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0")Integer rows ,String gua_state) {


        ZhongkaiResult result = guardService.listGuard(page,rows,gua_state);

        return result;
    }



    /**
     * 修改用户状态
     *
     * @param uuid        用户id
     * @param gua_state 用户状态
     */

    @RequestMapping(value = "/guard/leave", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult guard_leave(String uuid, String gua_state) {


        ZhongkaiResult result = guardService.leaveGuard(uuid,gua_state);

        return result;
    }
}
